package com.irishud.hudnavi;

import android.content.Context;
import android.content.SharedPreferences;
import android.content.SharedPreferences.Editor;
import android.content.SharedPreferences.OnSharedPreferenceChangeListener;

public class Sysconfig implements OnSharedPreferenceChangeListener {
	private final String LOG_TAG = "Sysconfig";
	private Context mContext;
	private Editor mEditor;
	private SharedPreferences mPreference;
	
	private String tag = "systemconfig";
//	private final String notifypushState = "cof_notifypush";//消息推送开关
	private final String navivoiceState = "cof_navivoice";//导航播报开关
//	private final String captureTime = "cof_capture";//行车记录仪秒数
	private final String navipathType = "cof_navipathtype";//导航路径
//	private final String FmState = "cof_fm";//FM开关
//	private final String FmName = "cof_namefm";//FM开关
	private final String Navichangetype="cof_navichangetype";//导航模式复杂简单切换
	private static final String NaviSupportExtGPS = "cof_navsupportgps";
	private String OnBoardNavi = "cof_onBoardNavi";
    private String SystemScreenBrightness = "cof_system_screen_brightness";


	public Sysconfig(Context context) {
		mContext = context.getApplicationContext();
		// mPreference =
		// PreferenceManager.getDefaultSharedPreferences(mContext);
		mPreference = mContext.getSharedPreferences(tag, 0);
		mPreference.registerOnSharedPreferenceChangeListener(this);
		mEditor = mPreference.edit();
	}

	public boolean isSimpleNaviMode() {
		return mPreference.getBoolean(Navichangetype, true);
	}

	public void setSimpleNaviMode(boolean navichangetype) {
		mEditor.putBoolean(Navichangetype, navichangetype);
		mEditor.commit();
	}
	
	public void setExtGPSStatus(int extGPSStatus){
		mEditor.putInt(NaviSupportExtGPS, extGPSStatus);
		mEditor.commit();
	}
	
	public int extGPSStatus(){
		return mPreference.getInt(NaviSupportExtGPS, 0);
	}
	
	@Override
	public void onSharedPreferenceChanged(SharedPreferences arg0, String arg1) {
	}

    public boolean isOnBoardNavi(){
        return mPreference.getBoolean(OnBoardNavi, true);
    }


    public void setOnBoardNavi(boolean how){
        mEditor.putBoolean(OnBoardNavi, how);
        mEditor.commit();
    }

    public int getSystemBrightness(){
        return mPreference.getInt(SystemScreenBrightness, 50);
    }

    public void setSystemBrightness(int value){
        mEditor.putInt(SystemScreenBrightness, value);
        mEditor.commit();
    }
}
